#include<bits/stdc++.h>
#define int long long
using namespace std;
inline int max(int a,int b){
    return a>b?a:b;
}inline int min(int a,int b){
    return a<b?a:b;
}
int n,m,l,v;
struct node{
    int di,vi,ai;
}a[100007];
int p[100007],pre[100007],rpre[100007];
const double eps=1e-6;
inline long double speed(int x,int s){
    return sqrt(a[x].vi*a[x].vi+2*a[x].ai*s);
}
inline bool check(int idp,int x){
    if(a[x].di>p[idp])return 1;
    int dis=p[idp]-a[x].di;
    if(dis<0)return 1;
    double spd=speed(x,dis);
    return spd-v<eps;
}
inline void sol(int x,int id){
    int l=id,r=m,ans=0;
    while(l<=r){
        int mid=l+r>>1;
        if(check(mid,x)){
            l=mid+1,ans=mid;
        }else r=mid-1;
    }pre[x]=ans;
}
int dans,fans=0;
bool vis[22];
bool ok(int x){
    for(int i=1;i<=m;++i){
        if(vis[i])continue;
        if(!check(i,x))return 1;
    }return 0;
}
void ffs(int x,int now){
    if(x>m){
        int sum=0;
        for(int i=1;i<=n;++i){
            sum+=ok(i);
        }if(sum==dans)fans=max(fans,m-now);
        return;
    }vis[x]=1;
    ffs(x+1,now);
    vis[x]=0;
    ffs(x+1,now+1);
}
signed main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);

    int T;cin>>T;while(T--){
        cin>>n>>m>>l>>v;
        int cnt=0,ans=0;
        bool f=1;
        for(int i=1;i<=n;++i){
            cin>>a[i].di>>a[i].vi>>a[i].ai;
        }for(int i=1;i<=m;++i){
            cin>>p[i];
        }if(n<0){
            dans=0,fans=0;
            for(int i=1;i<=n;++i){
                bool f=0;
                for(int j=1;j<=m;++j){
                    f=(!check(j,i));
                    if(f){
                        //cout<<i<<" "<<j<<"\n";
                        break;
                    }//cout<<i<<" "<<j<<" "<<a[i].di<<" "<<p[j]<<endl;
                    if(a[i].ai<0&&a[i].di<p[j])break;

                }dans+=f;

            }
            cout<<dans<<" ";
            memset(vis,0,sizeof vis);
            ffs(1,0);
            cout<<fans<<"\n";
            continue;
        }
        for(int i=1;i<=n;++i){
            int l=1,r=m,Ans=-1;
            while(l<=r){
                int mid=l+r>>1;
                if(p[mid]>=a[i].ai){
                    r=mid-1,Ans=mid;
                }else l=mid+1;
            }
            if(Ans!=-1&&a[i].ai==0){
                if(a[i].di<=p[m]&&a[i].vi>v){
                    ans++;
                }
                continue;
            }else sol(i,Ans);
            if(a[i].ai>0){
                cnt++;
                if(!check(m,i))ans++;
            }f=0;
        }if(cnt==n||f){
            if(ans)cout<<ans<<" "<<m-1<<"\n";
            else cout<<"0 "<<m<<"\n";
            continue;
        }
    }
    return 0;
}
